package com.it.test;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ResponseAttribute {
    /**
     * 重定向model创建共享域
     * @return
     */
    @RequestMapping("resp1")
    public String add(Model model) {
        model.addAttribute("name","xiaoxin");
        return "test01";
    }

    /**
     * 重定向ModelAndView创建共享域
     * @return
     */
    @RequestMapping("resp2")
    public ModelAndView add() {
        ModelAndView mv = new ModelAndView();
        mv.addObject("name","xiaoxin");
        mv.setViewName("redirect:/test");
        return mv;
    }
}
